#include <stdio.h>

int main(){
    char str[100];
    scanf("%s",str);
    int count=0;
    int count2=99;
    char a=str[0];
    char b=str[99];
    while (count<count2){
        a=str[count];
        if (a=='('||a=='{'||a=='['){
            b=str[count2];
            while (a!=b){
                if (b==')'||b=='}'||b==']'){printf("false");return 0;};
                if (count2==count){printf("false");return 0;};
                count2--;
                if (a=='{'||b=='}')break;
                if (a=='('||b==')')break;
                if (a=='['||b==']')break;
                b=str[count2];
                }
        if (count!=count2)count++;
        } 
    }
    printf("true");



    return 0;
}

